import {baseUrl} from "@/config/env";
import actFormOption from "@/option/start/formEngine/formOption";

import optionUtils from "@/option/optionUtils";
import actFormApi from "@/api/start/activiti/actFormApi";

const startActFormOption = actFormOption();
for (let i = 0; i < startActFormOption.column.length; i++) {
    if (startActFormOption.column[i].prop === 'tablePreVersion') {
        startActFormOption.column[i].hide = true
    }
}

function getActFormOption() {
    return {
        menuBtn: false,
        column: [
            {
                label: "表单类型",
                type: 'select',
                prop: "confKey",
                dicUrl: baseUrl + "/startActDicApi/getActFormStore",
                span: 24,
            },
            {
                label: "流程表单",
                type: 'table',
                prop: "confVal",
                children: startActFormOption,
                onLoad: (onLoadParams, callback) => {
                    onLoadParams.pageDefinition = actFormApi.list
                    onLoadParams.valueDefinition = actFormApi.getById
                    onLoadParams.option = startActFormOption;
                    let searchParams = {};
                    searchParams.form_category = ""
                    searchParams.start_order_tableVersion = "desc"
                    onLoadParams.searchParams = searchParams;
                    const customCallBack = (data) => {
                        if (!onLoadParams.value) {
                            callback(data)
                            return
                        }
                        data = data || {}
                        callback(data)
                    }
                    optionUtils.tableOnLoad(onLoadParams, customCallBack)
                },
                props: {
                    label: "formName",
                    value: "id",
                },
                span: 24,
                formatter: function (data) {
                    if (!data.id) {
                        return null
                    }
                    return data.formName + "_v" + data.tableVersion;
                }
            }
        ]
    }
}

const actPropertiesFormOption = {
    getActFormOption
}
export default actPropertiesFormOption
